/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package spaceshooter;

import it.randomtower.engine.World;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;

/**
 *
 * @author Bensch
 */
public class GameWorld extends World {
    public static int levelNum = 0;
    public static Level level;
    
    public GameWorld(int id, GameContainer gc) {
        super(id,gc);
    }
    
    @Override
    public void init(GameContainer gc, StateBasedGame game) throws SlickException {
        super.init(gc, game);
    }
    
    private void loadLevel(StateBasedGame game) {
        levelNum++;
        if(Level.levelExists(levelNum)){
            this.clear();
            Ship s = new Ship(getWidth() / 2, getHeight() / 2);
            add(s);
            level = Level.load(levelNum, this);
        }
    }
    
    @Override
    public void enter(GameContainer gc, StateBasedGame game) throws SlickException {
        super.enter(gc, game);
        loadLevel(game);
    }
    @Override
    public void update(GameContainer gc, StateBasedGame game, int delta) throws SlickException {
        super.update(gc, game, delta);
    }
    
    @Override
    public void render(GameContainer gc, StateBasedGame game, Graphics g) throws SlickException {
        super.render(gc, game, g);
    }
}
